{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution:\n",
    "    def longestCommonPrefix(self, strs: [str]) -> str:\n",
    "        prefix = ''\n",
    "        if len(strs) == 0:\n",
    "            return prefix\n",
    "        \n",
    "        min_len = 2**31-1\n",
    "        str_id = -1\n",
    "        for i in range(len(strs)):\n",
    "            if len(strs[i]) < min_len:\n",
    "                min_len = len(strs[i])\n",
    "                str_id = i\n",
    "        print(min_len, str_id)\n",
    "        for loc in range(min_len):\n",
    "            ch = strs[str_id][loc]\n",
    "            for i in range(len(strs)):\n",
    "                if strs[i][loc] != ch:\n",
    "                    return prefix\n",
    "            prefix = prefix + ch\n",
    "        return prefix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = Solution()\n",
    "s.longestCommonPrefix([])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py3",
   "language": "python",
   "name": "py3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
